package cn.iocoder.yudao.module.dbit.dal.mysql.policynew;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.dbit.dal.dataobject.policynew.PolicyNewDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.dbit.controller.admin.policynew.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 政策新闻 Mapper
 *
 * @author 大奔
 */
@Mapper
public interface PolicyNewMapper extends BaseMapperX<PolicyNewDO> {

    default PageResult<PolicyNewDO> selectPage(PolicyNewPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PolicyNewDO>()
                .eqIfPresent(PolicyNewDO::getTitle, reqVO.getTitle())
                .eqIfPresent(PolicyNewDO::getSource, reqVO.getSource())
                .eqIfPresent(PolicyNewDO::getContent, reqVO.getContent())
                .betweenIfPresent(PolicyNewDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PolicyNewDO::getId));
    }


    @Select("SELECT * FROM dbit_policy_new ORDER BY create_time DESC LIMIT #{number}")
    List<StudentPolicyNewReqVO> selectLatestPolicyNew(@Param("number") Integer number);
}